package com.ticket.api.controller;

import com.ticket.common.time.CommonFunction;
import com.ticket.db.entity.TblMarketInfo;
import com.ticket.api.service.TbMarketInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/marketInfo")
public class TbMarketInfoController {
    private static Logger logger = LoggerFactory.getLogger(TbMarketInfoController.class);

    @Autowired
    TbMarketInfoService tbMarketInfoService;

    @RequestMapping("/getMarketInfo")
    public List<TblMarketInfo> findTblMarketInfoByCondition(TblMarketInfo info) {
        try {
            List<TblMarketInfo> list = tbMarketInfoService.findTblMarketInfoByCondition(info);
            for (int item=0;item<list.size();item++) {
                list.get(item).setLastUpdateTime(CommonFunction.Toyymmdd(list.get(item).getLastUpdateTime()));
            }
            return list;
        }catch (Exception e){
            logger.error("TbMarketInfoController>>findTblMarketInfoByCondition:"+e);
        }
      return null;
    }

    @RequestMapping("/instMarketInfo")
  public   boolean insertTblMarketInfo(TblMarketInfo info ){
        try {
           return tbMarketInfoService.insertTblMarketInfo(info);
        }catch (Exception e){
            logger.error("TbMarketInfoController>>insertTblMarketInfo："+e);
            return  false;
        }
    }
}

